<?php if(isset($this->all_items)){?>
	
	<script type="text/javascript">
		function showDescription(obj){
			$$('.ja-job-description').setStyle('display', 'block');
			$E('#ja-control-description .hide').setStyle('display', '');
			$E('#ja-control-description .show').setStyle('display', 'none');
		}
		function hideDescription(){
			$$('.ja-job-description').setStyle('display', 'none');
			$E('#ja-control-description .hide').setStyle('display', 'none');
			$E('#ja-control-description .show').setStyle('display', '');
		}
	</script>
	
	<?php global $jbconfig;?>
	
	 <?php 
    $filter_order = JRequest::getVar('filter_order', 'emplo.featured');
	$filter_order_dir	= JRequest::getVar("filter_order_Dir",	"DESC"); 
	?>
	
	<!-- BOX ACTION TOP -->
	<?php if (count($this->all_items)>0) {?>
	<div id="ja-box-action-top">
		<?php if(!isset($module)){?>	   
	    <div class="ja-sortlist clearfix">
			<span><label for="filter_order_2"><?php echo JText::_('Sort By')?>:</label></span>
			<?php if(substr(trim($filter_order), 0, 2)=='a.') $filter_order = substr(trim($filter_order), 2);?>
			<select class="sortby" onchange="document.emplForm.method='get';$('task').value=''; $('filter_order').value=this.value; document.emplForm.submit();" name="filter_order_2" id="filter_order_2">
			 	<option value="emplo.featured" <?php if($filter_order=='emplo.featured'){?>selected="selected"<?php }?>><?php echo JText::_('Featured Employer')?></option>
				<option value="a.created_date" <?php if($filter_order=='created_date'){?>selected="selected"<?php }?>><?php echo JText::_('Date')?></option>
				<option value="a.location_id" <?php if($filter_order=='location_id'){?>selected="selected"<?php }?>><?php echo JText::_('Location')?></option>
				<!--<option value="a.title" <?php if($filter_order=='title'){?>selected="selected"<?php }?>><?php echo JText::_('Job Title')?></option>-->
				<option value="a.company" <?php if($filter_order=='company'){?>selected="selected"<?php }?>><?php echo JText::_('Company Name')?></option>
			</select>
			
			<select class="sortby" onchange="document.emplForm.method='get';$('filter_order_Dir').value=this.value; document.emplForm.submit();" name="filter_order_Dir_2" id="filter_order_Dir_2">
				<option value="asc" <?php if($filter_order_dir=='asc'){?>selected="selected"<?php }?>><?php echo JText::_('ASC')?></option>
				<option value="desc" <?php if($filter_order_dir=='desc'){?>selected="selected"<?php }?>><?php echo JText::_('DESC')?></option>
			</select>
		</div>
		<?php }?>	
		
		<div id="ja-control-description">
			<a class="button show" href="javascript:showDescription()" style="display: none">
				<span style="vertical-align: top ! important;"><?php echo JText::_('Show Profile Descriptions')?></span>
			</a>
			<a class="button hide" href="javascript:hideDescription()">
				<span style="vertical-align: top ! important;"><?php echo JText::_('Hide Profile Descriptions')?></span>
			</a>			
		</div>			
	</div>
	<?php }?>
	
	<!-- BOX ACTION TOP -->
	
	<!-- JA JOBLIST -->
	<div id="ja-joblist">		
		<ol id="ja-searchjoblist">
			
			<?php
		  	$items = $this->all_items;
		  	$k = 0;
		  	$orderNo = 0;
		  	$currentTable = '';
		  	$max_length = $jbconfig['posts']->get('posts_description_chars')? $jbconfig['posts']->get('posts_description_chars'):150;		  	
		  	for($ii = 0, $nn = count($this->fieldlist); $ii < $nn; $ii++ ){
		  		$field = $this->fieldlist[$ii];
                $field_name = $field->field_name;                        
		  	}
		  
		  	for($i = 0, $n = count($this->all_items); $i < $n; $i++, $orderNo++){
		   		$item = $items[$i];
		   		JFilterOutput::objectHTMLSafe( $item );
		   		if (is_numeric($item->user_id))
	    			$temp_user = JFactory::getUser($item->user_id);
	    		else 
	    		{
	    			$temp_user = new stdClass();
	    			$temp_user->username = $item->user_id;
	    		}
	    		$temp_user->username = str_replace('.','()',$temp_user->username);
		   		$class = '';		   		
		   		if($item->featured==1) $class = "premiumjob";
		   		if(!is_array($item->cat_id)) $cats = explode(',', $item->cat_id);
		   		else $cats = $item->cat_id;	   	

				if(is_array($item->location_id_tmp)) $locations = implode(',', $item->location_id_tmp);
		   		else $locations = $item->location_id_tmp;
		   		$location_names = getLocation($locations);
		   		$locations = explode(',',$location_names);
		   		?>         
		   		
		   		<?php 
				//Get Logo size
				if (!$item->logo)
				{
					$item->logo = JURI::base () . 'components/com_jajobboard/images/no-image.gif';
				}
				$logo_size = jaGetImageSize($item->logo);
				$logo_width = $logo_size['width'];
				$logo_height = $logo_size['height'];
				$item->short_desc = htmlspecialchars_decode($item->short_desc);
				?> 	 
						
				<li id="li_<?php echo $item->id; ?>" class="<?php echo $class?>  row<?php echo ($i%2); ?> <?php if ($i+1==$n): echo 'last'; endif;?>" onmouseover="$(this).addClass('hover')" onmouseout="$(this).removeClass('hover')">
					<div class="ja-job-details">
						
						<!-- JOB TITLE -->
						<h3 class="ja-job-title">
							<?php $alias = JFilterOutput::stringURLSafe(trim($item->company));?>
							<a href="<?php echo JRoute::_( 'index.php?option='. JBCOMNAME .'&view=japrofiles&layout=jaview&cid[]='.$temp_user->username."&profile_id=".$temp_user->username); ?>"  class="<?php echo $class;?>">
								<?php echo $item->company; ?>
							</a>	
							 <?php if($item->featured) { ?>
								<img width="57" height="15" alt="Featured Job" src="components/com_jajobboard/views/japrofiles/tmpl/themes/summary/images/featured.png"/>		
							 <?php }?>				
							
		         		</h3>
		         		<!-- //JOB TITLE -->
						
						<div class="col-left">
							
							<div class="ja-job-category clearfix">
		          				<label><?php echo JText::_('Location')?></label>				
								<?php foreach ($locations as $location) { ?>
		            				<a href="<?php echo JRoute::_('index.php?option=com_jajobboard&view=japrofiles&layout=filter_profile&location_id='.$location)?>" title="<?php echo $cat?>"><?php echo $location?></a> 
		            			<?php } ?>
							</div>
							<?php if(isset($item->business_type)){?>
							<div class="ja-job-category clearfix">
								<label><?php echo JText::_('Business type')?></label>
								<?php echo $item->business_type?>	
		          			</div>	       
		          			<?php }?>   										
						</div>
						
						<div class="col-right">
							<div class="ja-job-category dateAdded">
								<label><?php echo JText::_('Join Date')?></label>
								<span class="datetime">
									<?php if($jbconfig['general']->get('posts_show_published_date', 1)) { ?>
										<?php echo generatTimeStamp(strtotime($item->created_date))?>
									<?php } else { ?>
										<?php echo generateDate($item->created_date)?>
									<?php } ?>
								</span>
		          			</div>
		          			
		          			<div class="ja-job-category logo">
			          			 <a href="<?php echo JRoute::_( 'index.php?option='. JBCOMNAME .'&view=japrofiles&layout=jaview&cid[]='.$temp_user->username."&profile_id=".$temp_user->username); ?>"  class="<?php echo $class;?>">
					            	<img src="<?php echo $item->logo?>" alt="<?php echo $item->company?>" class="logo" align="left" width="<?php echo $logo_width?>" height="<?php echo $logo_height?>"/>
					             </a>
					        </div>
						</div>
						
						<div class="ja-job-description clearfix">
							<?php echo SmartTrim::trim($item->short_desc,0,$max_length) ?>
						</div>
					</div>  					
        		</li>
		            
		  <?php } ?>
	 	</ol>
	 </div>
	 <!-- //JA JOBLIST -->
	 
	<?php if(!JRequest::getVar('ajax') && isset($this->pagination)){?>
		<div class="jobs-pagination clearfix">			
			<?php echo $this->pagination->getPagesLinks(); ?>
		</div>
	<?php } elseif(isset($this->pagination)) {?>
		<div class="jobs-pagination clearfix">
			<div class="limit">
				<label for="limit"><?php echo JText::_("Display num")?></label>
				<?php echo $this->getListLimit(JRequest::getInt('limit', $jbconfig['posts']->get('display_num'))); ?>
			</div>
			
			<?php echo $this->pagination->getPagesLinks(); ?>
		</div>
	<?php } ?>
		 
<?php } ?>